package com.letwal.cmcvnd.aviewmodel

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations
import com.letwal.cmcvnd.adata.withdraw.ReqWithdrawCreate
import com.letwal.cmcvnd.base.BaseViewModel
import com.letwal.cmcvnd.anetwork.ApiUserReposity

class WithdrawViewModel : BaseViewModel() {

    //////////////////////////////////////////
    private val mWithdrawCreateLiveData = MutableLiveData<ReqWithdrawCreate>()

    val onWithdrawCreateLiveData =
        Transformations.switchMap(mWithdrawCreateLiveData) { query ->
            ApiUserReposity.withdrawCreate(this, query)
        }

    fun withdrawCreate(reqWithdrawCreate: ReqWithdrawCreate) {
        mWithdrawCreateLiveData.value = reqWithdrawCreate
    }

    //////////////////////////////////////////
    private val mWithdrawGetBalanceLiveData = MutableLiveData<ReqWithdrawCreate>()

    val onWithdrawGetBalanceLiveData =
        Transformations.switchMap(mWithdrawGetBalanceLiveData) { query ->
            ApiUserReposity.withdrawGetBalance(this, query)
        }

    fun withdrawGetBalance(reqWithdrawCreate: ReqWithdrawCreate) {
        mWithdrawGetBalanceLiveData.value = reqWithdrawCreate
    }
}